package org.wangnian.validationdemo.model;

import lombok.Data;
import org.wangnian.validationdemo.groups.user.InsertUser;
import org.wangnian.validationdemo.groups.user.UpdateUser;
import org.wangnian.validationdemo.validator.annotation.InEnum;
import org.wangnian.validationdemo.validator.enums.GenderEnum;

import javax.validation.Valid;
import javax.validation.constraints.*;


public class UserRequest {
//    @NotBlank(message = "用户ID不能为空")
    private String userId;

//    @NotBlank(message = "电话号码不能为空")
//    @Pattern(regexp = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$",message = "电话号码格式错误")
    private String mobilePhone;

//    @Min(message = "年龄必须大于0",value = 0)
//    @Max(message = "年龄必须小于150",value = 150)
//    @NotNull(message = "年龄不能为空")
    private Integer age;

//    @NotNull(message = "用户详细信息不能为空")
//    @Valid
    private UserDetails userDetails;

//    @InEnum(enumType = GenderEnum.class,message = "用户性别不在枚举范围内")
    private String gender;

    @NotBlank(message = "用户ID不能为空",groups = {UpdateUser.class})
    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    @NotBlank(message = "电话号码不能为空",groups = {UpdateUser.class, InsertUser.class})
    @Pattern(regexp = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$",message = "电话号码格式错误",groups = {UpdateUser.class, InsertUser.class})
    public String getMobilePhone() {
        return mobilePhone;
    }

    public void setMobilePhone(String mobilePhone) {
        this.mobilePhone = mobilePhone;
    }

    @Min(message = "年龄必须大于0",value = 0,groups = {UpdateUser.class, InsertUser.class})
    @Max(message = "年龄必须小于150",value = 150,groups = {UpdateUser.class, InsertUser.class})
    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @NotNull(message = "用户详细信息不能为空",groups = {UpdateUser.class, InsertUser.class})
    @Valid
    public UserDetails getUserDetails() {
        return userDetails;
    }

    public void setUserDetails(UserDetails userDetails) {
        this.userDetails = userDetails;
    }

    @InEnum(message = "用户性别不在枚举范围内",groups = {UpdateUser.class,InsertUser.class})
    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }
}
